package com.qw.qrweb.service.impl;

import com.qw.qrweb.mapper.ContentMapper;
import com.qw.qrweb.model.entity.ContentEntity;
import com.qw.qrweb.service.ContentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class ContentServiceImpl implements ContentService {

    @Resource
    private ContentMapper contentMapper;

    @Override
    public int addContent(String content) {
        // 获取当前时间
        Date now = new Date();
        // 定义时间格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 H点mm分ss秒");
        // 格式化当前时间
        String formattedDate = sdf.format(now);
        contentMapper.addContent("text", content, formattedDate);
        return 0;
    }

    @Override
    public ContentEntity getLastest() {
        return contentMapper.lastest();
    }


}
